﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIA.Foundation;
using VIA.Foundation.Services;
using VIA.Presentation;

namespace VIA.SiMoJi.Presentation
{
    [ViewModel(typeof(IManualMESConfirmView))]
    public class ManualMESConfirmViewModel : ViewModel<IManualMESConfirmView>
    {
        readonly IServiceProvider _service;
        readonly ICommandFactory _commandFactory;

        string _warnMessage;
        bool _state;
        public string WarnMessage
        {
            get => _warnMessage;
            set => SetProperty(ref _warnMessage, value);
        }
        public bool State
        {
            get => _state;
            set => SetProperty(ref _state, value);
        }
        public IRelayCommand ConfirmationOKCommand { get; }
        public IRelayCommand CancelCommand { get; }
        public ManualMESConfirmViewModel(IServiceProvider service)
        {
            _service = service;
            _commandFactory = _service.GetService<ICommandFactory>();
            ConfirmationOKCommand = _commandFactory.Create(() => ConfirmationOK());
            CancelCommand = _commandFactory.Create(() => Cancel());
        }
        void ConfirmationOK()
        {
            State = true;
            View.CloseDialog();
        }
        void Cancel()
        {
            State = false;
            View.CloseDialog();
        }
    }
}
